package com.durablemethods.tsmserver;

import java.io.IOException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import com.durablemethods.tsmserver.home.SummaryHome;
import com.durablemethods.tsmserver.model.TeamSummary;
import com.google.appengine.tools.util.Logging;

@SuppressWarnings("serial")
public class SummaryServlet extends HttpServlet{
	private SummaryHome summaryHome = new SummaryHome();
	private Logger log = Logger.getLogger("LoggerForThis");
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		resp.setContentType("text/plain");
		List<TeamSummary> summaries = summaryHome.getSummaryList();
		resp.getWriter().println("Team,Shares,Cost,Last, Last Trade");	
		for (TeamSummary ts : summaries) {
			String line = String.format("%s,%s,%s,%s,%s", ts.getTeamName(), ts.getInitialShares(), ts.getTotal(), ts.getLast(),ts.getLastTrade());
			resp.getWriter().println(line);			
		}
	}
	
		
}
